import time
from hashlib import blake2b as hash_
from hashlib import sha256

import os
import math

def getHash512():
    file="E:/server_HB/Guests/移动硬盘同步/SOYOVT13.iso"
    size = os.path.getsize(file)
    file = open(file,"rb")
    hash = sha256()
    n=0
    bs=1024*1024*32
    ab=math.ceil(size/bs)
    #print(size)
    #print(ab)
    while 1:
      #处理该行的代码
        data = file.read(bs)
        if(len(data)==0):
            break
        hash.update(data)
        n=n+1
        #print(int(n/ab*100))
    file.close()
    return hash.hexdigest()

def getHashblake2b():
    file="E:/server_HB/Guests/移动硬盘同步/SOYOVT13.iso"
    size = os.path.getsize(file)
    file = open(file,"rb")
    hash = hash_()
    n=0
    bs=1024*1024*32
    ab=math.ceil(size/bs)
    #print(size)
    #print(ab)
    while 1:
      #处理该行的代码
        data = file.read(bs)
        if(len(data)==0):
            break
        hash.update(data)
        n=n+1
        #print(int(n/ab*100))
    file.close()
    return hash.hexdigest()

begintime=time.time()
print(getHashblake2b())
print(time.time()-begintime)
print('getHashblake2b()')

begintime=time.time()
print(getHash512())
print(time.time()-begintime)
print("getHash512()")

begintime=time.time()
print(getHash512())
print(time.time()-begintime)
print("getHash512()")

begintime=time.time()
print(getHashblake2b())
print(time.time()-begintime)
print('getHashblake2b()')
